package top.ddandang.blog.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.ddandang.blog.bean.GlobalResponse;
import top.ddandang.blog.service.WeChatServer;

import javax.annotation.Resource;

/**
 * <p>
 *
 * </p>
 *
 * @author: D
 * @since: 2020/9/6
 * @version: 1
 */
@RestController
@RequestMapping("/we_chat")
public class WeChatController {

    @Resource
    WeChatServer weChatServer;

    @GetMapping("/getAccessToken")
    public GlobalResponse getAccessToken() {
        try {
            String accessToken = weChatServer.getAccessToken();
            return GlobalResponse.success().data("accessToken", accessToken);
        } catch (RuntimeException e) {
            return GlobalResponse.failed().message("获取失败，请稍后再试！");
        }
    }
}
